import elementLibraryManager from "../../ElementLibraryManager";

/**
 * @type {LibraryItem|null}
 */
let curItem = null;

const deleteElementLibraryItem = {
  /**
   * 校验选中的要素项能否使用删除
   * @param _ 忽略
   * @param item {LibraryItem}
   */
  validate(_, item) {
    curItem = item;
    return true;
  },
  execute() {
    if (!curItem) return;
    elementLibraryManager.deleteItem(curItem.id);
  }
}

export default deleteElementLibraryItem;